The stack's restricted access, mandated by the FILO principle, is strictly enforced through a standardized set of procedures.

  • All primary stack manipulation operations center around updating the top index, which maintains the state of the stack.
  • The five fundamental stack operations are:
    • Primary Operations (Manipulation):
      • push: Inserts a new element at the index $top + 1$.
      • pop: Removes the element currently pointed to by top and then decrements the pointer.
    • Helper Operations (Status Checks):
      • peek (or top): Returns the value at the current top position without removing it.
      • isEmpty: A check ensuring no underflow occurs ($top == -1$).
      • isFull: A check ensuring no overflow occurs ($top == n - 1$).

Fundamental Stack Operations

Operation Description
push(element) Adds an element to the top of the stack.
pop() Removes and returns the top element.
peek() Returns the top element without removing it.
isEmpty() Checks if the stack is empty.
isFull() Checks if the stack has reached its capacity.